<template>
  <div>
    <el-card class="box-card" shadow="never">
      <div slot="header" class="header-card">
        <span class="header-card-title">处置记录</span>
      </div>
      <el-row>
        <el-col :span="24">
          <el-table :data="ruleForm.disposalRecordLogs" border style="width: 100%">
            <el-table-column label="操作" align="center" fixed="left" width="220">
              <template #default="{row}">
                <el-button size="mini" type="text" @click="handleView(row)">
                  查看
                </el-button>

                <el-button size="mini" type="text" @click="handleUploadContract(row)"
                           v-if="[6].includes(Number(row.disposalStatus)) && row.isBreach === 0">
                  上传合同
                </el-button>

                <el-button size="mini" type="text" @click="handleUnderwriterDefault(row)"
                           v-if="[6,7,8,9].includes(Number(row.disposalStatus)) && row.isBreach === 0">
                  承销商违约
                </el-button>

                <el-button size="mini" type="text" @click="handleSubmitPaymentProof(row)"
                           v-if="[7].includes(Number(row.disposalStatus)) && row.isBreach === 0">
                  提交付款凭证
                </el-button>

                <el-button size="mini" type="text" @click="handleUploadAccount(row)"
                           v-if="row.isUploadUnderwriter !== null &&  Number(row.isUploadUnderwriter) === 0">
                  上传违约付款凭证/账户
                </el-button>

              </template>
            </el-table-column>

            <el-table-column label="成交价(元)" prop="finalPrice" min-width="120" show-overflow-tooltip align="center">
              <template #default="{row}">
                {{ format_thousand(row.finalPrice) }}
              </template>
            </el-table-column>

            <el-table-column label="差额(元)" prop="priceDifference" min-width="120" show-overflow-tooltip
                             align="center">
              <template #default="{row}">
                {{ format_thousand(row.priceDifference) }}
              </template>
            </el-table-column>

            <el-table-column label="承销商" prop="underwriterName" min-width="180" show-overflow-tooltip
                             align="center"/>

            <el-table-column label="合同附件" min-width="120" show-overflow-tooltip align="center">
              <template #default="{row}">
                {{ selectDictLabel(dict.type.approval_upload, row.contractUploadStatus) }}
              </template>
            </el-table-column>

            <el-table-column label="付款凭证" min-width="120" show-overflow-tooltip align="center">
              <template #default="{row}">
                {{ selectDictLabel(dict.type.approval_upload, row.paymentUploadStatus) }}
              </template>
            </el-table-column>

            <el-table-column label="收款核销状态" min-width="120" show-overflow-tooltip align="center">
              <template #default="{row}">
                {{ selectDictLabel(dict.type.collection_verification_status, row.collectionVerificationStatus) }}
              </template>
            </el-table-column>

            <el-table-column label="是否违约" prop="isBreach" min-width="100" show-overflow-tooltip align="center">
              <template #default="{row}">
                <span>{{ row.isBreach === 1 ? '是' : row.isBreach === 0 ? '否' : '-' }}</span>
              </template>
            </el-table-column>

            <el-table-column label="违约金额(元)" min-width="130" prop="defaultPenalty" align="center">
              <template #default="{row}">
                {{ format_thousand(row.defaultPenalty) }}
              </template>
            </el-table-column>

            <el-table-column label="违约金付款方式" min-width="140" show-overflow-tooltip align="center">
              <template #default="{row}">
                <span v-if="row.defaultPenalty">
                  {{
                    row.paymentMethod === '0' ? '已付金额抵扣' : row.paymentMethod === '1' ? '单独支付' : '-'
                  }}
                </span>
                <span v-else>/</span>
              </template>
            </el-table-column>

            <el-table-column label="违约金付款凭证" min-width="140" show-overflow-tooltip align="center">
              <template #default="{row}">
                <span v-if=" row.isBreach === 0 || ['',null,undefined,0,].includes(row.defaultPenalty) ||
                row.paymentMethod === '0'">
                  /</span>
                <span v-else>{{
                    selectDictLabel(dict.type.approval_upload, row.paymentBreachUploadStatus) || '/'
                  }}</span>
              </template>
            </el-table-column>

            <el-table-column label="承销商收款账户" prop="underwriterBankAccount" min-width="180" show-overflow-tooltip
                             align="center">
              <template #default="{row}">
                {{ selectDictLabel(dict.type.approval_upload, row.underwriterBankAccount) || '-' }}
              </template>
            </el-table-column>

            <el-table-column label="提交时间" min-width="140" show-overflow-tooltip align="center">
              <template #default="{row}">
                {{ row.commitTime || '-' }}
              </template>
            </el-table-column>

            <el-table-column label="提交人" min-width="120" align="center" prop="commitName">
              <template #default="{row}">
                {{ row.commitName || '-' }}
              </template>
            </el-table-column>
          </el-table>
        </el-col>
      </el-row>
    </el-card>
    <!--上传合同-->
    <uploadContractDialog ref="refUploadContractDialog" @refresh="refresh"/>
    <!--承销商违约-->
    <underwriterDefault ref="refUnderwriterDefault" @refresh="refresh"/>
    <!--提交付款凭证-->
    <paymentDocument ref="refPaymentDocument" @refresh="refresh"/>
    <!--  上传违约付款凭证/账户  -->
    <uploadAccount ref="refUploadAccount" @refresh="refresh"/>
  </div>
</template>

<script>
import uploadContractDialog from "./uploadContractDialog.vue";
import underwriterDefault from "./underwriterDefault.vue";
import paymentDocument from "./paymentDocument.vue";
import uploadAccount from "./uploadAccount.vue";

export default {
  name: "disposalRecord", //处置记录
  dicts: ["collection_verification_status", "approval_upload"],
  props: {
    value: {
      type: Object,
      default: () => {
      },
    },
  },
  components: {
    uploadContractDialog,
    underwriterDefault,
    paymentDocument,
    uploadAccount,
  },
  computed: {
    ruleForm: {
      get() {
        let that = this;
        const proxy = new Proxy(that.value, {
          get(target, key) {
            return Reflect.get(target, key);
          },
          set(target, key, value) {
            that.$emit("input", {...target, [key]: value});
            return true;
          },
        });
        return proxy;
      },
    },
  },
  watch: {},
  data() {
    return {
      tableData: [{a: "4545454545"}],
    };
  },
  created() {
  },
  mounted() {
  },
  methods: {
    //查看
    handleView() {
      this._toPage({
        path: "/VehicleDisposal/RoutineDisposal/DisposalResultDetails",
        name: "DisposalResultDetails",
        query: {
          type: "view",
          id: this.$route.query.id,
          vehicleDisposalNo: this.$route.query.vehicleDisposalNo,
        },
      });
    },

    //上传合同
    handleUploadContract(row) {
      row.vehicleDisposalId = this.$route.query.id;
      this.$refs.refUploadContractDialog.handleOpen(row.vehicleDisposalId);
    },

    //承销商违约
    handleUnderwriterDefault(row) {
      row.vehicleDisposalId = this.$route.query.id;
      this.$refs.refUnderwriterDefault.handleOpen(row);
    },

    //提交付款凭证
    handleSubmitPaymentProof(row) {
      row.vehicleDisposalId = this.$route.query.id;
      this.$refs.refPaymentDocument.handleOpen(row);
    },

    //上传违约付款凭证/账户
    handleUploadAccount(row) {
      row.vehicleDisposalId = this.$route.query.id;
      this.$refs.refUploadAccount.handleOpen(row);
    },

    refresh() {
      this.$emit('refresh')
    }
  },
};
</script>

<style scoped lang="scss">
@import "@/styles/cwgd/formScss.scss";
</style>


